package com.share.shareplatform.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Pattern;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {

    private Long id;

    private Long roleId;

    @Pattern(regexp = "^[A-Za-z0-9]{3,20}$",message = "账号只能是数字或字母，且长度为3-20")
    private String username;


    @Pattern(regexp = "^[A-Za-z0-9]{3,20}$",message = "密码只能是数字或字母，且长度为3-20")
    private String password;


    @Length(max=20,message ="名称太长")
    private String name;

    @Pattern(regexp = "^1[0-9]{10}$",message = "请求入正确的电话号码")
    private String phone;

    private Role role;

    public static void setInit(User user) {
        user.setRoleId(Role.Role_user);
    }
}
